package com.vclee.fast.integration.power;

import com.vclee.fast.integration.power.model.SysMenu;
import com.vclee.fast.integration.power.service.SysMenuService;
import com.vclee.fast.utils.aspect.SysLog;
import com.vclee.fast.utils.exception.R;
import com.vclee.fast.utils.model.Bson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/admin-sysMenu")
public class SysMenuController {
    @Resource
    private SysMenuService sysMenuService;

    @SysLog("管理端添加系统菜单")
    @PostMapping(value = "/addMenu")
    public R addMenu(@RequestBody SysMenu sysMenu){
        sysMenuService.addMenu(sysMenu);
        return R.ok();
    }

    @SysLog("管理端修改系统菜单")
    @PostMapping(value = "/editMenu")
    public R editMenu(@RequestBody SysMenu sysMenu){
        sysMenuService.editMenu(sysMenu);
        return R.ok();
    }

    @SysLog("管理端删除系统菜单")
    @PostMapping(value = "/delMenu")
    public R delMenu(@RequestBody SysMenu sysMenu){
        sysMenuService.delMenu(sysMenu);
        return R.ok();
    }

    @SysLog("后台查询系统菜单列表")
    @PostMapping(value = "/findListByQuery")
    public R findListByQuery(@RequestBody Bson query){
        return R.ok(sysMenuService.findListByQuery(query));
    }

}
